package com.train.pattern.strategy.v2.pay;

/**
 * @author hgx61
 * @create 2021-01-15 11:00
 */
public enum MemberTypeEnum {

    COMMON(0,"普通会员"),
    VIP(1,"VIP会员"),
    GOLD_CARD(2,"金卡会员");

    private final Integer code;
    private final String desc;

    MemberTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static MemberTypeEnum getMemberType(Integer code) {
        for (MemberTypeEnum memberType : MemberTypeEnum.values()) {
            if (memberType.getCode().equals(code)) {
                return memberType;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "MemberTypeEnum{" + "code=" + code + ", desc='" + desc + '\'' + '}';
    }
}
